Procedure control descriptor-based code specialization for context sensitive memory disambiguation

ABSTRACT

A computer implemented method for facilitating debugging of source code. The source code is scanned to identify a candidate region. A procedure control descriptor is generated, wherein the procedure control descriptor corresponds to the candidate region. The procedure control descriptor identifies, for the candidate region, a condition which, if true at runtime means that the candidate region can be specialized. Responsive to a determination during compile time that satisfaction of at least one condition will be known only at runtime, the procedure control descriptor is used to specialize the candidate region at compile time to create a first version of the candidate region for execution in a case where the condition is true and a second version of the candidate region for execution in a case where the condition is false, and further generate code to correctly select one of the first region and the second region at runtime.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention relates generally to an improved data processingsystem and in particular to compilers. Still more particularly, thepresent invention relates to a computer implemented method, apparatus,and a computer usable program product for performing code specializationduring compile time.

2. Description of the Related Art

Compilers are used to transform a program written in a first language toa second language. Most often, a computer program is translated fromsource code written in a language that is easily read by humans intoexecutable code written in a language that can be easily used by acomputer. Computer programmers often seek ways to maximize theefficiency of executable code during the compilation process. Thisprocess is called “optimization”. The word “optimization” and relatedterms are terms of art that refer to improvements in speed and/orefficiency of a computer program, and do not purport to indicate that acomputer program has achieved, or is capable of achieving, an “optimal”or perfectly speedy or perfectly efficient state.

A problem associated with optimizing executable code concerns how theexecutable code performs memory access. Because the addresses of memorylocations being accessed are not known until the executable program isexecuted, the compiler often takes a conservative approach and executesmemory accesses commands in the sequential order of the source code. Toprevent errors during memory access, the compiler usually placesartificial dependencies between memory references to ensure that thememory references are executed in sequential order.

One form of compilation optimization related to memory access commandsin the source code is known as memory disambiguation. A given set ofmemory access commands is considered ambiguous if the compiler cannotdetermine whether the memory access commands access different regions ofmemory. A given set of memory access commands is not consideredambiguous if the compiler can determine that the memory access commandsdo not access the same memory region. Memory disambiguation refers toperforming analysis on code during compile time to determine whetherreal dependencies actually exist for a pair of ambiguous memoryreferences.

Ambiguous memory references have traditionally been one of the mainsources of performance bottlenecks in the final executable program.Static disambiguation techniques have been proposed and used when memoryaccess patterns of the program are linear and predictable. However,these static techniques are ineffective when the memory access patternis non-linear or when the access program cannot be determinedstatically.

Specializing source code with respect to runtime values is anoptimization strategy that has been shown to drastically improve codeperformance on executable programs. Runtime is the time in whichexecutable code is executed. Program specialization speeds up programexecution by selectively executing different optimized versions of theprogram code, depending on the circumstances that actually exist atruntime. Code specialization can be applied to the compilertransformation in order to provide alternate paths of control to befollowed based upon the results of runtime memory ambiguity checks.However, runtime memory ambiguity checks can introduce additionalcomputing overhead, which is undesirable.

SUMMARY OF THE INVENTION

Exemplary illustrative embodiments provide for a computer implementedmethod, apparatus, and computer usable program code for compiling sourcecode. In an illustrative example, the source code is scanned to identifya candidate region. A procedure control descriptor is generated, whereinthe procedure control descriptor corresponds to the candidate region.The procedure control descriptor identifies, for the candidate region, acondition which, if true at runtime means that the candidate region canbe specialized. The illustrative example further includes, responsive toa determination during compile time that satisfaction of at least onecondition will be known only at runtime, using the procedure controldescriptor to specialize the candidate region at compile time to createa first version of the candidate region for execution in a case wherethe condition is true and a second version of the candidate region forexecution in a case where the condition is false. Code is furthergenerated to select one of the first region and the second region atruntime.

Another illustrative example includes, responsive to a determinationduring compile time that the condition will always be true at runtime,optimizing the candidate region at compile time according tosatisfaction of the condition. The determination that the condition willbe true at runtime can be context sensitive. In another illustrativeexample, when a procedure is called from a first call site the conditionis true, and wherein when the procedure is called from a second callsite the condition is not always true.

In another illustrative example, at least one code region having a codespecialization opportunity is identified. A code specializationopportunity occurs when the at least one code region containscorresponding candidate code that can be disambiguated during compiletime. An alias analysis is performed to select at least one procedure,wherein the at least one procedure contains the candidate code. At leastone procedure control descriptor is associated with corresponding onesof the at least one code regions. A corresponding procedure controldescriptor has a corresponding flag parameter of a corresponding flagand the corresponding flag parameter identifies that a correspondingcode region contains corresponding candidate code. Specialization isperformed, at compile time, of selected ones of the at least one coderegions having the code specialization opportunity.

In another illustrative example, identifying further includes building acorresponding call graph for each at least one procedure and traversingthe call graph in reverse depth-first order. In yet another illustrativeexample, identifying further includes, for each node of eachcorresponding call graph, examining a corresponding procedure toidentify the code specialization opportunity. In yet anotherillustrative example, identifying further includes creating at least oneadditional procedure control descriptor for at least one correspondingcandidate code region for which at least one code specializationopportunity exists if a condition is true. For each at least one codespecialization opportunity, a code specialization predicate is createdfor late evaluation.

In yet another illustrative example, performing alias analysis furtherincludes performing procedural pointer analysis to create aliasrelationships refining aliases for all pointer variables. In yet anotherillustrative example, performing alias analysis further includesconstructing a corresponding alias bit vector to describe the aliasrelationships for corresponding ones of the at least one procedurecontrol descriptor for each corresponding call edge from correspondingones of the at least one procedure. In yet another illustrative example,performing alias analysis further includes, for each at least oneprocedure, responsive to an existence of a corresponding predecessoredge from an undefined procedure and at least two alias bit vectorsbeing different, cloning the corresponding undefined procedure, updatinga corresponding call graph for each at least one code region, andaliasing the corresponding alias bit vector. In yet another illustrativeexample, performing alias analysis further includes for each at leastone procedure, responsive to the corresponding at least one procedurebeing a defined procedure and at least two alias bit vectors beingdifferent, selecting the corresponding procedure as the codespecialization opportunity.

In yet another illustrative example, associating further includestraversing, in reverse depth first order, a corresponding call graph foreach at least one code region. In yet another illustrative example,associating further includes modifying corresponding call sites with acorresponding value of a corresponding argument of the correspondingflag parameter. In yet another illustrative example, associating furtherincludes adding the corresponding flag parameters. In yet anotherillustrative example, associating further includes updating each atleast one procedure control descriptor with a corresponding symbol thatidentifies the corresponding flag.

In yet another illustrative example, performing code specializationfurther includes determining, for each at least one code region, whethercode specialization is needed, wherein the determination is made basedon an availability of a corresponding procedure control descriptor forthe corresponding at least one procedure. In yet another illustrativeexample, performing code specialization further includes versioning theat least one code region using a corresponding symbol that correspondswith each at least one procedure control descriptor, wherein thecorresponding symbol identifies the corresponding flag. In yet anotherillustrative example, performing code specialization further includescomputer usable program code for creating second corresponding symbols,wherein the second corresponding symbols contain additional aliasinginformation; and computer usable program code for replacing thecorresponding symbols with the second corresponding symbols.

Another illustrative embodiment for specializing code includes gatheringintra-procedural information during a forward pass compilation of thecode;

-   -   traversing a call graph of the code in reverse depth-first        order;    -   for each procedure of code, creating a corresponding procedure        control descriptor for the corresponding candidate procedure,        wherein at least one candidate procedure is a part of at least        one code region;    -   performing an intra-procedural alias analysis for all pointer        variables referenced in the corresponding candidate procedure;    -   collecting alias relationships for each at least one candidate        procedure;    -   analyzing the alias relationships for arguments of pointer        types, wherein analyzing is performed at the end of the forward        pass compilation when all nodes in the call graph have been        traversed;    -   refining corresponding aliases for all pointer variables for the        code;    -   computing the alias relationships for arguments of pointer type        at all call sites for all procedures, wherein, for each        procedure, all predecessor edges of a corresponding procedure        node are traversed;    -   constructing a corresponding bit vector to describe the alias        relationships for each corresponding call edge of the call        graph, if the corresponding call edge is from a defined        procedure;    -   examining sets of formal parameters in the corresponding        procedure control descriptor;    -   for each set of formal parameters in the corresponding procedure        control descriptor, computing the alias relationships for the        arguments, and recording a corresponding bit value in the        corresponding bit vector;    -   responsive to all the arguments in a given set being determined        as not aliasing each other, recording a first bit value for the        given set, otherwise, recording a second bit value in the given        set;    -   responsive to the corresponding bit vectors for at least two of        the predecessor edges from the defined procedures being        different, and responsive to an existence of a predecessor edge        from an undefined procedure, cloning each corresponding        procedure to form a corresponding cloned procedure;    -   replacing a corresponding call site by calling the corresponding        cloned procedure, copying the corresponding procedure control        descriptor from the corresponding cloned procedure, and updating        the call graph by moving all call edges from the defined        procedure as predecessors of the corresponding cloned procedure;    -   responsive to alias bit vectors for at least two predecessor        edges from the defined procedure being different, and responsive        to at least two predecessor edges of the corresponding procedure        all being from defined procedures, selecting a corresponding        procedure as a candidate procedure for interface change and code        versioning;    -   modifying the code during a backward pass by traversing the call        graph in a depth-first order and, for each defined procedure,        modifying all the call sites with new interfaces using a        procedure interface descriptor;    -   modifying a corresponding call interface for the at least one        candidate procedure by, responsive to the at least one candidate        procedure being a candidate for interface change and code        versioning, creating a new formal parameter;    -   creating an extra formal parameter for at least one candidate        procedure, wherein a corresponding symbol identifying the new        formal parameter is created;    -   building a corresponding procedure interface descriptor for the        at least one candidate procedure;    -   recording an interface change in the corresponding procedure        interface descriptor, wherein a corresponding entry in the        corresponding procedure interface descriptor is added for the        new formal parameter, wherein the corresponding entry contains        the corresponding symbol and a type of the formal parameter;    -   modifying the corresponding call interface with the new formal        parameter;    -   updating the corresponding procedure control descriptor with the        corresponding symbol;    -   for each set of formal parameters in the corresponding procedure        control descriptor, responsive to alias bit vectors for at least        two predecessor edges from the defined procedure being        different, updating an attribute field with the corresponding        symbol of the new formal parameter;    -   for each set of formal parameters in the corresponding procedure        control descriptor, responsive to all alias bit vectors of the        defined procedure being the same, indicating uniform alias        relationships for the set of the formal parameters and        propagating the uniform alias relationships to the at least one        candidate procedure;    -   versioning the at least one code region using a corresponding        procedure control descriptor condition based on the        corresponding procedure control descriptor;    -   creating, for each corresponding procedure control descriptor        condition, at least one new corresponding symbol having more        precise aliasing information; and    -   replacing the corresponding symbols with the at least one new        corresponding symbol.

BRIEF DESCRIPTION OF THE DRAWINGS

The novel features believed characteristic of the invention are setforth in the appended claims. The invention itself, however, as well asa preferred mode of use, further objectives and advantages thereof, willbest be understood by reference to the following detailed description ofan illustrative embodiment when read in conjunction with theaccompanying drawings, wherein:

FIG. 1 is a pictorial representation of a data processing system, inwhich illustrative embodiments may be implemented;

FIG. 2 is a block diagram of a data processing system, in whichillustrative embodiments may be implemented;

FIG. 3 is a block diagram of a prior art process for compiling sourcecode;

FIG. 4 is exemplary pseudo code demonstrating a memory ambiguity;

FIG. 5 shows exemplary pseudo code as shown in FIG. 4, but modified toshow code specialization with runtime ambiguity checks;

FIG. 6 shows exemplary pseudo code containing memory ambiguities;

FIG. 7 is a block diagram illustrating a process taken by a compiler forprocedure control descriptor based code specialization for contextsensitive memory disambiguation, in accordance with an illustrativeembodiment;

FIG. 8 shows an exemplary procedure containing candidate code regionsfor code specialization, in accordance with an illustrative embodiment;

FIG. 9 shows pseudo code, in which procedure “foo” calls procedure “bar”twice;

FIG. 10 shows pseudo code, in which procedure control descriptor basedspecialization is performed on the callee “bar,” in accordance with anillustrative embodiment;

FIG. 11 is a block diagram showing two exemplary call contexts, in whichthe callee is called at two call sites and there are two regions in thecallee, in accordance with an illustrative embodiment;

FIG. 12 is a block diagram showing the specialization of a callee,wherein both regions are specialized and the region that is to beexecuted at runtime is determined by the flag passed from the call site,in accordance with an illustrative embodiment;

FIG. 13 is a flowchart showing a process of performing procedure controldescriptor-based code specialization for context sensitivedisambiguation, in accordance with an illustrative embodiment;

FIG. 14 is a flowchart showing a process for identifying code regionsfor code specialization opportunities, in accordance with anillustrative embodiment;

FIG. 15 is a flowchart illustrating a process for performing aliasanalysis to select candidate procedures for code specialization, inaccordance with an illustrative embodiment;

FIG. 16 is a flowchart illustrating a process for adding a fly parameterfor procedure control descriptors and modifying corresponding call sitesin a procedure, in accordance with an illustrative embodiment;

FIG. 17 is a flowchart illustrating a process for performing codespecialization for candidate code regions, in accordance with anillustrative embodiment;

FIG. 18 is a flowchart illustrating a method of procedure controldescriptor-based code specialization for context sensitive memorydisambiguation, in accordance with an illustrative embodiment; and

FIG. 19 shows pseudo code for specializing a memory region in accordancewith an illustrative embodiment.

DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENT

With reference now to the figures, and in particular with reference toFIG. 1, a pictorial representation of a data processing system is shown,in which an illustrative embodiment may be implemented. Computer 100includes system unit 102, video display terminal 104, keyboard 106,storage devices 108, which may include floppy drives and other types ofpermanent and removable storage media, and mouse 110. Additional inputdevices may be included with personal computer 100. Examples ofadditional input devices could include, for example, a joystick, atouchpad, a touch screen, a trackball, and a microphone.

Computer 100 may be any suitable computer, such as an IBM® Server™computer or IntelliStation® computer, which are products ofInternational Business Machines Corporation, located in Armonk, N.Y.Although the depicted representation shows a personal computer, otherembodiments may be implemented in other types of data processingsystems. For example, other embodiments may be implemented in a networkcomputer. Computer 100 also preferably includes a graphical userinterface (GUI) that may be implemented by means of systems softwareresiding in computer readable media in operation within computer 100.

Next, FIG. 2 depicts a block diagram of a data processing system, inwhich illustrative embodiments may be implemented. Data processingsystem 200 is an example of a computer, such as computer 100 in FIG. 1,in which code or instructions implementing the processes of theillustrative embodiments may be located.

In the depicted example, data processing system 200 employs a hubarchitecture including a north bridge and memory controller hub (NB/MCH)202 and a south bridge and input/output (I/O) controller hub (SB/ICH)204. Processing unit 206, main memory 208, and graphics processor 210are coupled to north bridge and memory controller hub 202. Processingunit 206 may contain one or more processors and even may be implementedusing one or more heterogeneous processor systems. Graphics processor210 may be coupled to the NB/MCH through an accelerated graphics port(AGP), for example.

In the depicted example, local area network (LAN) adapter 212 is coupledto south bridge and I/O controller hub 204, audio adapter 216, keyboardand mouse adapter 220, modem 222, read only memory (ROM) 224, universalserial bus (USB) and other ports 232. PCI/PCIe devices 234 are coupledto south bridge and I/O controller hub 204 through bus 238. Hard diskdrive (HDD) 226 and CD-ROM 230 are coupled to south bridge and I/Ocontroller hub 204 through bus 240.

PCI/PCIe devices may include, for example, Ethernet adapters, add-incards, and PC cards for notebook computers. PCI uses a card buscontroller, while PCIe does not. ROM 224 may be, for example, a flashbinary input/output system (BIOS). Hard disk drive 226 and CD-ROM 230may use, for example, an integrated drive electronics (IDE) or serialadvanced technology attachment (SATA) interface. A super I/O (SIO)device 236 may be coupled to south bridge and I/O controller hub 204.

An operating system runs on processing unit 206. This operating systemcoordinates and controls various components within data processingsystem 200 in FIG. 2. The operating system may be a commerciallyavailable operating system, such as Microsoft® Windows XP®. (Microsoft®and Windows XP® are trademarks of Microsoft Corporation in the UnitedStates, other countries, or both). An object oriented programmingsystem, such as the Java™ programming system, may run in conjunctionwith the operating system and provides calls to the operating systemfrom Java programs or applications executing on data processing system200. Java and all Java-based trademarks are trademarks of SunMicrosystems, Inc. in the United States, other countries, or both.

Instructions for the operating system, the object-oriented programmingsystem, and applications or programs are located on storage devices,such as hard disk drive 226. These instructions and may be loaded intomain memory 208 for execution by processing unit 206. The processes ofthe illustrative embodiments may be performed by processing unit 206using computer implemented instructions, which may be located in amemory. An example of a memory is main memory 208, read only memory 224,or in one or more peripheral devices.

The hardware shown in FIG. 1 and FIG. 2 may vary depending on theimplementation of the illustrated embodiments. Other internal hardwareor peripheral devices, such as flash memory, equivalent non-volatilememory, or optical disk drives and the like, may be used in addition toor in place of the hardware depicted in FIG. 1 and FIG. 2. Additionally,the processes of the illustrative embodiments may be applied to amultiprocessor data processing system.

The systems and components shown in FIG. 2 can be varied from theillustrative examples shown. In some illustrative examples, dataprocessing system 200 may be a personal digital assistant (PDA). Apersonal digital assistant generally is configured with flash memory toprovide a non-volatile memory for storing operating system files and/oruser-generated data. Additionally, data processing system 200 can be atablet computer, laptop computer, or telephone device.

Other components shown in FIG. 2 can be varied from the illustrativeexamples shown. For example, a bus system may be comprised of one ormore buses, such as a system bus, an I/O bus, and a PCI bus. Of coursethe bus system may be implemented using any suitable type ofcommunications fabric or architecture that provides for a transfer ofdata between different components or devices attached to the fabric orarchitecture. Additionally, a communications unit may include one ormore devices used to transmit and receive data, such as a modem or anetwork adapter. Further, a memory may be, for example, main memory 208or a cache such as found in north bridge and memory controller hub 202.Also, a processing unit may include one or more processors or CPUs.

The depicted examples in FIG. 1 and FIG. 2 are not meant to implyarchitectural limitations. In addition, the illustrative embodimentsprovide for a computer implemented method, apparatus, and computerusable program code for compiling source code and for executing code.The methods described with respect to the depicted embodiments may beperformed in a data processing system, such as data processing system100 shown in FIG. 1 or data processing system 200 shown in FIG. 2.

The data processing system described in FIG. 1 and FIG. 2 can be used tocompile code using the illustrative examples described herein. Inparticular, the compilation methods of the illustrative embodimentsallow code that contains some ambiguous memory allocations to bespecialized with respect to unambiguous runtime values without requiringa full runtime memory ambiguity check. In an illustrative example, ageneral compiler method is shown for combining static analysis andruntime checking through procedure control descriptor-based codespecialization for context sensitive memory disambiguation.

The following terms have the following meanings, as used herein. Thesedefinitions apply to corresponding claim terms.

A “procedure,” also known as a function, is one or more lines of codethat correspond to a particular process to be performed upon executionof the code.

The term “disambiguated” means that ambiguous memory allocation commandsin the source code are resolved. Ambiguous commands in the source codeare resolved when the ambiguity is resolved.

The term “ambiguous memory allocation command” means that a command insource code contains a memory allocation command or request thatpossibly may not be resolvable until runtime.

The term “undefined procedure” means that if the intermediaterepresentation for a particular procedure is not available, then theprocedure is undefined. In an illustrative example, an undefinedprocedure would be a similar code name linked to compile code.

The term “defined procedure” means a procedure that is not an undefinedprocedure.

The term “formal parameter” refers to a dummy variable associated with aprocedure definition. As part of a procedure definition, the formalparameter is declared with type and name. The formal parameter providesstorage space for the value of the actual argument which appears as partof the procedure call.

A “code specialization opportunity” is a condition in which at least onecode region within the code contains a candidate procedure that can bedisambiguated during compile time.

The term “actual argument” refers to the actual value or referenceassigned to a formal parameter variable when a procedure is called.

A “procedure interface descriptor” is a set of formal parameters. Thedata structure of a procedure interface descriptor is used to keep trackof formal parameters for procedures. Each procedure has one descriptor.The descriptor may contain entries for retaining formal parameters, deadparameters to be removed, or new parameters to be added for variousoptimizations of the source code.

The term “procedure control descriptor” is a list of region procedurecontrol descriptors. Each procedure has a procedure control descriptor.

The term “region procedure control descriptor” refers to a datastructure that contains context dependent information, such as formalparameters of pointer type for memory disambiguation. Each candidatecode region has a record in its owner's procedure control descriptor.

A “call graph” represents the calling relationship of the procedures ina computer program. Stated differently, a call graph represents acalling relationship among subroutines in a computer program.Specifically, a call graph is a directed multi-graph, which includes aset of nodes for each procedure and edges for each procedure call. Eachedge is directed starting from a caller node and ending at a calleenode.

A “mask” is some data that is used along with an operation to extractinformation stored elsewhere. A 1 bit in a mask is used to control thecorresponding bit found in the data.

“Alias analysis” is a technique in compiler theory, used to determine ifa storage location may be accessed in more than one manner. Two pointersare said to be aliased if the two pointers point to the same memorylocation.

“Pointer analysis” is a static code analysis technique that establisheswhich pointers, or heap references, can point to which variables orstorage locations.

An “alias bit vector” for a procedure call describes the aliasrelationships for each call edge if the call edge is from a definedprocedure.

The term “specialized” means that source code has been modified toimprove runtime performance.

In an illustrative embodiment, a procedure control descriptor isintroduced for each code region with a specific code specializationopportunity in a procedure to recode the context dependent information.During global analysis at different compilation passes, some informationcan be evaluated and resolved at different control paths. If theinformation on memory disambiguation can be evaluated partially on somecontrol flow paths, then a procedure control descriptor is created andpassed to the callee. The procedure control descriptor is used as a baseto compute the control relationships for the interested actualpointer-type arguments. The procedure control descriptor reduces theruntime check overhead in the final executable code. Note that theillustrative embodiments can be applied to code specialization casesother than memory disambiguation.

In another illustrative embodiment, the source code is scanned toidentify a candidate region. A procedure control descriptor isgenerated, wherein the procedure control descriptor corresponds to thecandidate region. The procedure control descriptor identifies, for thecandidate region, a condition which, if true at runtime, means that thecandidate region can be specialized. Responsive to a determinationduring compile time that satisfaction of at least one condition will beknown only at runtime, the candidate region is specialized at compiletime to create a first version of the candidate region for execution ina case where the condition is true and a second version of the candidateregion for execution in a case where the condition is false. Alsoresponsive to the determination, code is further generated to correctlyselect one of the first region and the second region at runtime.

FIG. 3 is a block diagram of a prior art process for compiling sourcecode. The compilation process shown in FIG. 3 can be implemented in adata processing system, such as data processing system 100 shown in FIG.1 or data processing system 200 shown in FIG. 2.

In general, a compilation process transforms source code 300 usingcompiler 302 to form executable code 304. Thus, compiler 302 is acomputer program that translates source code 300 into executable code304. Source code 300 is a computer program written in a languagereadable by a human and executable code 304 is a program written in alanguage more easily readable by a computer or data processing system.

More generally, a compiler is a computer program that translates textwritten in a first computer language into a second computer language.Compilers come in many different types, such as single pass compilers,multi-pass compilers, decompilers, and translators. In the illustrativeexamples provided herein, a multi-pass compiler is used. A single passcompiler performs compilation by beginning translation at the beginningof source code 300 and continuing translation until the entirety ofsource code 300 is translated into executable code 304. In a multi-passcompiler, source code 300 may be passed over more than once by compiler302 during the compilation process. For example, source code 300 can becompiled in a forward direction from the beginning to the end, and thenin a backward direction from the end to the beginning.

The illustrative embodiments described herein relate to performing codespecialization on source code 300 during compilation by compiler 302.The problem solved by the illustrative embodiments described herein isdescribed in relation to FIGS. 4-6. The pseudo code shown in FIGS. 4-6is representative of code that could be implemented in a data processingsystem, such as data processing system 100 shown in FIG. 1 and dataprocessing system 200 shown in FIG. 2.

FIG. 4 is exemplary pseudo code demonstrating a memory ambiguity.Variables p and q are both pointers of 1 byte type. Variable N is theloop iteration counter of an integer type. Variable i is the loopinduction variable of an integer type. The pointers p and q may point tooverlapping regions of memory at runtime causing memory ambiguity,especially when the memory region from address p to (p+N) overlaps thememory region from address q to (q+N).

FIG. 5 shows exemplary pseudo code as shown in FIG. 4, modified to showcode specialization with runtime ambiguity checks. The loop in FIG. 4 islegally transformed into a memcpy( ) call only if there is no memoryoverlapping for the storage pointed by p and q.

FIG. 5 shows code specialization with runtime memory ambiguity check.The memory ambiguity check (((p+N)<q)∥((q+N)<p)) is true if there is nooverlapping between the memory region from address p to (p+N) and thememory region from address q to (q+N). Otherwise, the memory ambiguitycheck defined in the previous sentence is false. When the memoryambiguity check is true, the loop can be transformed into a call to thememcpy( ) call which could have a highly-optimized implementation toimprove the performance.

FIG. 6 shows exemplary pseudo code containing memory ambiguities. Theruntime memory ambiguity check for this example could be quitecomplicated, which results in extra runtime overhead. Three pointers arereferenced in the “while” loop, q, r, and q→pos. The memory ambiguitycheck needs to make sure no memory overlapping occurs among the memoryregion pointed-to by these three pointers at runtime.

Note that the pointer q is not changed in the loop. The check includescomparing the three memory regions, the memory region pointed-to by q,the memory region from r to (r+bytes_to_write), and the memory regionfrom q→pos to (q→pos+bytes_to_write), as shown in the right hand portionof FIG. 6. These complex comparisons will introduce more memory regioncomparisons of “if” condition branches, resulting in extra runtimeoverhead. If the compiler can determine for at least one of the callpaths that the storage pointed-to by r is disjointed with thatpointed-to by q→pos, the resulting extra runtime overhead due to thecheck can be reduced significantly with the procedure control descriptorbased code specification for context sensitive memory disambiguation.The term “disjointed” means that the memory area pointed-to by a memoryaccess command or a procedure is different than the memory area to whichanother memory access command or different procedure points.

FIG. 7 is a block diagram illustrating a process taken by a compiler forprocedure control descriptor based code specialization for contextsensitive memory disambiguation, in accordance with an illustrativeembodiment. The compilation method shown in FIG. 7 can be implemented ina data processing system, such as data processing system 100 shown inFIG. 1 or data processing system 200 shown in FIG. 2. The process shownin FIG. 7 can be implemented in a compiler, such as compiler 302 shownin FIG. 3.

The compilation shown in FIG. 7 begins with identifying code regionswith code specialization opportunities in stage 700. A codespecialization opportunity is a condition in which at least one coderegion within the code contains a candidate procedure that can bedisambiguated during compile time. A procedure is one or more lines ofcode that correspond to a particular process to be performed uponexecution of the code. The term disambiguated means that ambiguousmemory allocation commands in the source code are resolved. Ambiguouscommands in the source code are resolved when the ambiguity is resolved.Stage 700 can be performed, in one illustrative embodiment, throughintra-procedural compiler static analysis. For each candidate coderegion, a procedure control descriptor is created to evaluateexpressions and conditions that could result in code specialization.“Alias analysis” is a technique in compiler theory, used to determine ifa storage location may be accessed in more than one manner. Two pointersare said to be aliased if the two pointers point to the same memorylocation.

During stage 702, the compiler performs a multiple pass static analysisto evaluate and validate conditions incrementally. The compiler alsoselects procedures as candidates for code specialization based on therelationships of procedure control descriptors from each call.

During stage 704, the compiler adds a flag parameter for each procedurecontrol descriptor and modifies all corresponding call sites by passingalias information through the extra flag. During stage 706, codespecialization is performed for each candidate code region that has beenidentified in stage 702. During stage 706, code specialization isperformed.

FIG. 8 shows an exemplary procedure containing candidate code regionsfor code specialization, in accordance with an illustrative embodiment.The illustrative procedure described with respect to FIG. 7 isimplemented on a sample procedure shown in FIG. 8. The exemplary processdescribed with respect to the procedure shown in FIG. 8 can beimplemented in data processing system 100 as shown in FIG. 1 or dataprocessing system 200 as shown in FIG. 2. The illustrative example shownin FIG. 8 can be performed by a compiler, such as compiler 302 shown inFIG. 3.

In the example shown in FIG. 8, a procedure “foo” 800 contains twocandidate code regions for code specialization. These include firstcandidate code region 802 and second candidate code region 804. Firstcandidate code region 802 depends on arguments ptr1 and ptr3. Candidatecode region 804 depends on arguments ptr2, ptr3, and ptr4.

During the first stage, which corresponds to stage 700 in FIG. 7,procedure control descriptor 806 is created with two entries, includingentry 808 and entry 810 corresponding to first candidate code region 802and second candidate code region 804, respectively. The first stage canbe implemented during a forward pass compilation. The bit vector<1,0,1,0,0> is recorded in entry 808 to indicate that first candidatecode region 802 can be specialized if the memory locations pointed-to byptr1 and ptr3 are disjointed. Because ptr1 and ptr3 are disjointed, ptr1and ptr3 point to different memory locations. The bit vector <0,1,1,1,0>is recorded in entry 810 to indicate that second candidate code region804 can be specialized if the memory pointed-to by ptr2, ptr3, ptr4 aredisjointed. As can be seen, the elements of vectors <1,0,1,0,0> and<0,1,1,1,0> correspond to the pointers (ptr1, ptr2, ptr3, ptr4, ptr5)received as arguments by the function foo 800, with a “1” representing apointer on which there is a dependency, and a “0” representing a pointeron which there is no dependency.

During the second stage, which corresponds to stage 702 in FIG. 7,global information through control flow sensitive and insensitivepointer analysis is gathered. Pointer analysis is a static code analysistechnique that establishes which pointers, or heap references, can pointto which variables or storage locations. Three cases can arise whenperforming pointer analysis. In the first case, for all possible calledges, memory references can be disambiguated. In a second case, for allpossible call edges, memory references cannot be disambiguated. In athird case, for some call edges, memory references can be disambiguatedand for other call edges, memory references cannot be disambiguated.

For the first case, in which for all possible call edges, memoryreferences can be disambiguated, every code region can be specializedwithout code versioning. Thus, the first case represents a trivial casewhere all memory references can be disambiguated during compile time.For the second case, in which for all possible call edges memoryreferences cannot be disambiguated, runtime checking code is needed forcode versioning. Thus, the second case also represents a trivial case inwhich all memory allocation checking must take place during runtime.

For the third case, in an illustrative example, a mask is generated foreach candidate code region and an extra flag parameter is created forthe corresponding procedure. In the example shown in FIG. 8, the maskwill be 0x01 and 0x02 respectively, if code region one and two belong tothe third case. Procedure foo(ptr1, ptr2, ptr3, ptr4, and ptr5) will bechanged to procedure foo (ptr1, ptr2, ptr3, ptr4, ptr5, FLAG). For eachcall site, the call will be changed into a number of differentprocedures depending on memory references that can be disambiguated. Forexample, a call site can be changed to foo (ptr1, ptr2, ptr3, ptr4,ptr5, 0x0) if memory references cannot be disambiguated. In anotherillustrative example, a call can be changed to foo(ptr1, ptr2, ptr3,ptr4, ptr5, 0X01) if memory pointed by ptr1 and ptr3 can bedisambiguated. In another illustrative example, for a call site, a callcan be changed into foo (ptr1, ptr2, ptr3, ptr4, ptr5, 0X02) if memoryallocations parted by ptr2, ptr3, and ptr4 can be disambiguated. Inanother illustrative example, for a particular call site, a call can bechanged into foo (ptr1, ptr2, ptr3, ptr4, ptr5, 0X03) if memory printedby ptr1 and ptr3 can be disambiguated and memory pointed by ptr2, ptr3,and ptr4 can also be disambiguated.

After the transformations described above, the code region procedurecontrol descriptor, such as for example procedure control descriptor 806in FIG. 8, is updated with the symbol index for the new symbol of theextra flag parameter.

During the third stage, which corresponds to stage 704 in FIG. 7, a flagparameter is added for each procedure control descriptor of thecorresponding candidate procedure. Additionally, all corresponding callsites are modified by passing the extra parameter.

During the fourth stage, which corresponds to stage 706 in FIG. 7, codespecialization is performed for each candidate code region. In theexample shown in FIG. 8, first candidate code region 802 and secondcandidate code region 804 are both candidate code regions. An example ofa code specialization procedure is shown in the pseudo code in FIG. 9.Similar code can be used for first candidate code region 802 in FIG. 8,and, code similar to that shown in FIG. 9 can be modified to referencesecond candidate code region 804, as opposed to first candidate coderegion 802.

FIG. 9 is pseudo code in which procedure “foo”” calls procedure “bar”twice, in accordance with an illustrative embodiment. Procedure “bar”copies the content of the char array s1 and s2 to char array d1 and d2,respectively. Moreover, s1, s2, d1, and d2 are of the same length. Inprocedure “bar,” whether or not the sources (s1 and s2) overlap with thedestinations cannot be determined. In particular, whether or not thesources overlap depends on the calling context. A determination can bemade, at the fist call site, that the sources do not overlap thedestinations. However, s2 overlaps with d2 at the second call site.

FIG. 10 shows pseudo code in which procedure control descriptor basedspecialization is performed on the callee “bar,” in accordance with anillustrative embodiment. The compiler inserts a runtime check for eachregion to examine whether the source overlaps with the destination. Ifregion 1 and region 2 do not overlap, the memcpy( ) call, which isassumed to be faster and only works on non-overlapping source anddestination, can be used instead of the original code. Otherwise, theoriginal code is be used.

The two call sites pass an extra flag, which provides calling contextinformation regarding the overlapping relationships for the two pairs ofsources and destinations. In this example, 2 bits are used, one bit foreach pair. Therefore, the first call site passes 3, meaning there is nooverlapping for both pairs. The 2^(nd) call site passes 1, meaning onlythe first pair does not overlap.

FIG. 11 shows two exemplary call contexts in which the callee is calledat two call sites and there are two regions in the callee, in accordancewith an illustrative embodiment. FIG. 11 is a corresponding pictorialdepiction of the calling contexts, as shown in the pseudo code of FIG.9.

FIG. 12 is a block diagram showing the specialization of a callee,wherein both regions are specialized and the region that is to beexecuted at runtime is determined by the flag passed from the call site,in accordance with an illustrative embodiment. FIG. 12 is acorresponding pictorial representation of the calling contexts, as shownin the pseudo code of FIG. 10. The flag from the call site provides somecalling-context sensitive information. The compiler inserts code in thecallee to decide which region to execute according to the flag.

FIG. 13 is a flowchart showing a process of performing procedure controldescriptor based code specialization for content sensitivedisambiguation, in accordance with an illustrative embodiment. Theprocess shown in FIG. 13 can be implemented in a data processing system,such as data processing system 100 shown in FIG. 1 or data processingsystem 200 shown in FIG. 2. The process shown in FIG. 13 can beimplemented using a compiler, such as compiler 302 shown in FIG. 3. Theprocess shown in FIG. 13 corresponds to the stages shown in FIG. 7.

The process begins as the compiler identifies code regions with codespecialization opportunities (step 1300). The compiler then performsalias analysis to select candidate procedures for code specialization(step 1302). Candidate procedures can exist in one or more of the coderegions. The compiler then adds a flag parameter for procedure controldescriptors associated with corresponding candidate procedures and thenmodifies all corresponding call sites (step 1304). The complier thenperforms code specialization for selected ones of the candidate coderegions (step 1306). Candidate code regions are those code regionshaving a candidate procedure or candidate procedures.

FIG. 14 is a flowchart showing a process for identifying code regionsfor code specialization opportunities, in accordance with anillustrative embodiment. The process shown in FIG. 14 can be implementedin a data processing system, such as data processing system 100 shown inFIG. 1 or data processing system 200 shown in FIG. 2. The process shownin FIG. 12 can be implemented using a compiler, such as compiler 302shown in FIG. 3. The process shown in FIG. 14 also identifies the stepsthat can be taken to implement step 700 shown in FIG. 7.

The process begins as a compiler builds a call graph (step 1400). Thecall graph represents a calling relationship among subroutines in acomputer program. The compiler then traverses the call graph in reversestep first order (top down) (step 1402). The compiler then selects aparticular call graph mode (step 1404). The compiler then selects acandidate code region in a procedure (step 1406).

The compiler determines whether a code specialization opportunity existsfor the selected code region (step 1408). If a code specializationopportunity does not exist then the process skips to step 1414. If thecode specialization opportunity exists, then the compiler creates aprocedure control descriptor for the candidate code region (step 1410).The compiler also creates code specialization predicates (step 1412).Code specialization predicates are conditions for which thecorresponding code region can be specialized, if the conditions aretrue.

The compiler then determines whether additional code regions in theprocedure are to be processed (step 1414). If additional code regions inthe procedure are to be processed, then the process returns to step 1406and repeats. Otherwise, the compiler determines whether additional callgraph nodes are to be analyzed (step 1416). If additional call graphnodes are to be analyzed, then the process returns to step 1404 andrepeats. If the compiler determines, at step 1416, that there are noadditional call graph nodes to be analyzed, then the process terminates.

FIG. 15 is a flowchart illustrating a process for performing aliasanalysis to select candidate procedures for code specialization, inaccordance with an illustrative embodiment. The process shown in FIG. 15can be implemented in a data processing system, such as data processingsystem 100 shown in FIG. 1 and data processing system 200 shown in FIG.2. The process shown in FIG. 15 can be implemented in a compiler, suchas compiler 302 shown in FIG. 3. The process shown in FIG. 15 shows anexemplary method for performing step 702 in FIG. 7.

The process begins as the compiler performs pointer analysis (step1500). The compiler collects pointer alias relationships (step 1502).The compiler also refines aliases for all the pointer variables (step1504). The compiler then constructs an alias bit vector for procedurecontrol descriptors for a call edge from a defined procedure (step1506). An alias bit vector for a procedure call describes the aliasrelationships for each call edge if the call edge is from a definedprocedure.

The compiler then determines whether a predecessor edge from anundefined procedure exists (step 1508). If no such predecessor edge froman undefined procedure exists, then the process terminates. Otherwise,the compiler determines whether at least two alias bit vectors aredifferent from all known alias bit vectors (step 1510). If thiscondition is not satisfied, then the process terminates. Otherwise, thecompiler clones the procedure (step 1512). The compiler also updates thecall graph and the alias bit vector (step 1514).

Note that when the callee is called by undefined procedures, no extraparameter can be added. However, when an opportunity exists for thecalls from defined procedures, cloning is performed so that codeversioning can be performed on the cloned procedure. Alternatively,versioning may be performed on the original procedure and the clonedprocedure may remain unmodified; the effect is the same. Versioningallows a user to keep track of what version of code is currently beinganalyzed or modified.

The compiler then determines whether the procedure is called from adefined procedure (step 1516). If not, then the process terminates. Ifthe procedure is called from the defined procedure, then the compilerdetermines whether at least two alias bit vectors are different (step1518). If this condition is not satisfied, then the process terminates.Otherwise, the compiler selects the particular procedure as a candidatefor code specialization (step 1520). The process terminates thereafter.

FIG. 16 is a flowchart illustrating a process for adding a flagparameter for procedure control descriptors and modifying correspondingcall sites in a procedure, in accordance with an illustrativeembodiment. The process show in FIG. 16 can be implemented in a dataprocessing system, such as data processing system 100 shown in FIG. 1and data processing system 200 shown in FIG. 2. The process shown inFIG. 16 can be implemented using a compiler, such as compiler 302 shownin FIG. 3. The process shown in FIG. 16 illustrates an exemplary methodfor performing step 704 in FIG. 7.

The process begins as the compiler traverses a call graph in depth firstorder (bottom up) (step 1600). The compiler modifies all call sites byadding one extra flag parameter showing the calling context sensitivealiasing relationship (step 1602). The compiler then selects a procedurefor analysis (step 1604).

The compiler then determines whether the selected procedure is acandidate for code specialization (step 1606). If the selected procedureis not a candidate for specialization, then the process skips to step1612 to determine whether to select the next procedure. Otherwise, thecompiler adds a flag parameter to a corresponding procedure controldescriptor of the candidate procedure (step 1608). The compiler thenupdates the procedure control descriptor with a symbol that identifiesthe new added formal parameter (step 1610). The compiler then determineswhether to select another procedure (step 1612). If another procedure isto be selected, then the process returns to step 1604 and repeats.Otherwise, the process terminates.

FIG. 17 is a flowchart illustrating a process for performing codespecialization for candidate code regions, in accordance with anillustrative embodiment. The process shown in FIG. 17 can be implementedin a data processing system, such as data processing system 100 shown inFIG. 1 or data processing system 200 shown in FIG. 2. The process shownin FIG. 17 can be implemented using a compiler, such as compiler 302shown in FIG. 3. In particular, the process shown in FIG. 17 is a methodof performing step 706 shown in FIG. 7.

The process begins as the compiler determines whether a procedurecontrol descriptor is provided for a procedure (step 1700). If noprocedure control descriptor is provided for a procedure then theprocess proceeds to step 1708 to determine whether there is anotherprocedure to consider. Otherwise, the compiler specializes the coderegion containing the procedure (step 1702). The compiler then createsnew symbols with more precise aliasing information (step 1704), therebyindicating disjointed memory references. The compiler then replaces theoriginal symbols with the new symbols (step 1706). The compiler thendetermines whether to select another procedure (step 1708). If a newprocedure is to be selected, then the process returns to step 1700 andrepeats. Otherwise, the process terminates.

FIG. 18 is a flowchart illustrating a method of procedure controldescriptor-based code specialization for context sensitive memorydisambiguation, in accordance with an illustrative embodiment. Theprocess shown in FIG. 18 can be implemented in a data processing system,such as data processing system 100 shown in FIG. 1 or data processingsystem 200 shown in FIG. 2. The process shown in FIG. 18 can beimplemented using a compiler, such as compiler 302 shown in FIG. 3. Theprocess shown in FIG. 18 is an exemplary embodiment, which is similar tothe embodiment shown in FIG. 7.

The process begins as the compiler scans the source code to identify acandidate region (step 1800). The compiler then generates a procedurecontrol descriptor, wherein the procedure control descriptor correspondsto the candidate region, and wherein the procedure control descriptoridentifies, for the candidate region, a condition which, if true atruntime means that the candidate region can be specialized (step 1802).

Responsive to a determination during compile time that satisfaction ofthe least one condition will be known only at runtime, the procedurecontrol descriptor is used to specialize the candidate region at compiletime to create a first version of the candidate region for execution ina case where the condition is true, and a second version of thecandidate region for execution in a case where the condition is false,and further generating code to select one of the first region and thesecond region at runtime (step 1804).

In an illustrative embodiment, responsive to a determination duringcompile time that the condition will always be true at runtime, thecompiler optimizes the candidate region at compile time according tosatisfaction of the condition (step 1806). The process terminatesthereafter.

FIG. 19 shows pseudo code for specializing a memory region, inaccordance with an illustrative embodiment. The pseudo code shown inFIG. 19 is an example of pseudo code for performing code specializationon a candidate procedure. The pseudo code shown in FIG. 19 is used asdescribed with respect to the example shown in FIG. 8.

Thus, the compilation methods of the illustrative embodiments allow codethat contains some ambiguous memory allocations to be specialized withrespect to unambiguous runtime values without requiring a full runtimememory ambiguity check. In an illustrative example, a general compilermethod is shown for combining static analysis and runtime checkingthrough procedure control descriptor-based code specialization forcontext sensitive memory disambiguation.

The illustrative examples described herein may reduce the amount ofcloning required to handle different disambiguation scenarios fordifferent call sites. Reduction in cloning may be achieved by passingthe flag parameter with a mask for each candidate region.

Additionally, the illustrative embodiments described herein may reduceruntime costs from ambiguous memory commands by passing hints based oncompile time analysis to the resulting executable code. These hints alsoenable other optimizing compilers to use context based assumptions togenerate yet faster code. The hints take the form of procedure controldescriptors associated with each procedure in a code region. Thus, theillustrative embodiments described herein provide for methods ofcompiling source code which may in appropriate circumstances result inexecutable code that operates faster then executable code compiled byformerly known techniques.

The invention can take the form of an entirely software embodiment or anembodiment containing both hardware and software elements. In apreferred embodiment, the invention is implemented in software, whichincludes, but is not limited to, firmware, resident software, microcode,etc.

Furthermore, the invention can take the form of a computer programproduct accessible from a computer-usable or computer-readable mediumproviding program code for use by or in connection with a computer orany instruction execution system. For the purposes of this description,a computer-usable or computer readable medium can be any tangibleapparatus that can contain, store, communicate, propagate, or transportthe program for use by or in connection with the instruction executionsystem, apparatus, or device.

The medium can be an electronic, magnetic, optical, electromagnetic,infrared, or semiconductor system (or apparatus or device) or apropagation medium. Examples of a computer-readable medium include asemiconductor or solid state memory, magnetic tape, a removable computerdiskette, a random access memory (RAM), a read-only memory (ROM), arigid magnetic disk and an optical disk. Current examples of opticaldisks include compact disk-read only memory (CD-ROM), compactdisk-read/write (CD-R/W) and DVD.

Further, a computer storage medium may contain or store a computerreadable program code such that when the computer readable program codeis executed on a computer, the execution of this computer readableprogram code causes the computer to transmit another computer readableprogram code over a communications link. This communications link mayuse a medium that is, for example without limitation, physical orwireless.

A data processing system suitable for storing and/or executing programcode will include at least one processor coupled directly or indirectlyto memory elements through a system bus. The memory elements can includelocal memory employed during actual execution of the program code, bulkstorage, and cache memories which provide temporary storage of at leastsome program code in order to reduce the number of times code must beretrieved from bulk storage during execution.

Input/output or I/O devices (including but not limited to keyboards,displays, pointing devices, etc.) can be coupled to the system eitherdirectly or through intervening I/O controllers.

Network adapters may also be coupled to the system to enable the dataprocessing system to become coupled to other data processing systems orremote printers or storage devices through intervening private or publicnetworks. Modems, cable modem and Ethernet cards are just a few of thecurrently available types of network adapters.

The description of the present invention has been presented for purposesof illustration and description, and is not intended to be exhaustive orlimited to the invention in the form disclosed. Many modifications andvariations will be apparent to those of ordinary skill in the art. Theembodiment was chosen and described in order to best explain theprinciples of the invention, the practical application, and to enableothers of ordinary skill in the art to understand the invention forvarious embodiments with various modifications as are suited to theparticular use contemplated.

1. A computer program product comprising: a computer storage mediumhaving computer usable program code for specializing code, the computerprogram product including: computer usable program code for scanning thesource code to identify a candidate region, wherein the source code ofthe candidate region includes memory allocation commands; computerusable program code for generating a procedure control descriptor,wherein the procedure control descriptor comprises a data structurecontaining a list of region procedure control descriptors containingcontext dependent information which corresponds to the candidate region,and wherein the procedure control descriptor identifies, for thecandidate region, a condition which, if true at runtime means that thecandidate region can be specialized; and computer usable program code,responsive to a determination during compile time that satisfaction ofat least one condition will be known only at runtime, for using theprocedure control descriptor to specialize the candidate region atcompile time to create a first version of the candidate region forexecution in a case where the condition is true and a second version ofthe candidate region for execution in a case where the condition isfalse, and further generating code to correctly select one of the firstregion and the second region at runtime.
 2. The computer program productof claim 1 further comprising: computer usable program code for,responsive to a determination during compile time that the conditionwill always be true at runtime, optimizing the candidate region atcompile time according to satisfaction of the condition.
 3. The computerprogram product of claim 1, wherein the determination that the conditionwill be true at runtime is context sensitive.
 4. The computer programproduct of claim 3, wherein when a procedure is called from a first callsite the condition is true, and wherein when the procedure is calledfrom a second call site the condition is not always true.
 5. A computerprogram product comprising: a computer storage medium having computerusable program code for specializing code, the computer program productincluding: computer usable program code for performing alias analysis toidentify at least one candidate code region having a code specializationopportunity, wherein a code specialization opportunity occurs when theat least one candidate code region can be disambiguated during compiletime, wherein source code of the at least one candidate code regionincludes memory allocation commands; computer usable program code forselecting at least one procedure, wherein the at least one procedurecontains the corresponding at least one candidate code region; computerusable program code for associating at least one procedure controldescriptor with corresponding ones of the at least one procedure,wherein each corresponding procedure control descriptor comprises a datastructure containing a list of region procedure control descriptorscontaining context dependent information and has a corresponding flagparameter of a corresponding flag, wherein the corresponding flagparameter identifies that the corresponding at least one procedurecontains the corresponding at least one candidate code region; andcomputer usable program code for performing specialization, at compiletime, of selected ones of the at least one candidate code region havingthe code specialization opportunity.
 6. The computer program product ofclaim 5 wherein the computer usable program code for identifying furthercomprises: computer usable program code for building a correspondingcall graph for each at least one procedure; and computer usable programcode for traversing the call graph in reverse depth-first order.
 7. Thecomputer program product of claim 6 wherein the computer usable programcode for identifying further comprises: computer usable program codefor, for each node of each corresponding call graph, examining acorresponding procedure to identify the code specialization opportunity.8. The computer program product of claim 7 wherein the computer usableprogram code for identifying further comprises: computer usable programcode for creating at least one additional procedure control descriptorfor at least one corresponding candidate code region for which at leastone code specialization opportunity exists if a condition is true; andcomputer usable program code for, for each at least one codespecialization opportunity, creating a code specialization predicate forlate evaluation.
 9. The computer program product of claim 5 wherein thecomputer usable program code for performing alias analysis furthercomprises: computer usable program code for performing proceduralpointer analysis to create alias relationships; and computer usableprogram code for refining aliases for all pointer variables.
 10. Thecomputer program product of claim 9 wherein the computer usable programcode for performing alias analysis further comprises: computer usableprogram code for constructing a corresponding alias bit vector todescribe the alias relationships for corresponding ones of the at leastone procedure control descriptor for each corresponding call edge fromcorresponding ones of the at least one procedure.
 11. The computerprogram product of claim 10 wherein the computer usable program code forperforming alias analysis further comprises: computer usable programcode for, for each at least one procedure, responsive to an existence ofa corresponding predecessor edge from an undefined procedure and atleast two alias bit vectors being different, cloning the correspondingundefined procedure, updating a corresponding call graph for each atleast one procedure, and aliasing the corresponding alias bit vector.12. The computer program product of claim 11 wherein the computer usableprogram code for performing alias analysis further comprises: computerusable program code for, for each at least one procedure, responsive tothe corresponding at least one procedure being a defined procedure andat least two alias bit vectors being different, selecting thecorresponding procedure as the code specialization opportunity.
 13. Thecomputer program product of claim 5 wherein the computer usable programcode for associating further comprises: computer usable program code fortraversing, in reverse depth first order, a corresponding call graph foreach at least one procedure.
 14. The computer program product of claim13 wherein the computer usable program code for associating furthercomprises: computer usable program code for modifying corresponding callsites with a corresponding value of a corresponding argument of thecorresponding flag parameter.
 15. The computer program product of claim14 wherein the computer usable program code for associating furthercomprises: computer usable program code for adding the correspondingflag parameters.
 16. The computer program product of claim 15 whereinthe computer usable program code for associating further comprises:computer usable program code for updating each at least one procedurecontrol descriptor with a corresponding symbol that identifies thecorresponding flag.
 17. The computer program product of claim 5 whereinthe computer usable program code for performing code specializationfurther comprises: computer usable program code for determining, foreach at least one candidate code region, whether code specialization isneeded, wherein the determination is made based on an availability of acorresponding procedure control descriptor for the corresponding atleast one procedure.
 18. The computer program product of claim 17wherein the computer usable program code for performing codespecialization further comprises: computer usable program code forversioning the at least one code region using a corresponding symbolthat corresponds with each at least one procedure control descriptor,wherein the corresponding symbol identifies the corresponding flag. 19.The computer program product of claim 18 wherein the computer usableprogram code for performing code specialization further comprises:computer usable program code for creating second corresponding symbols,wherein the second corresponding symbols contain additional aliasinginformation; and computer usable program code for replacing thecorresponding symbols with the second corresponding symbols.
 20. Acomputer program product comprising: a computer storage medium havingcomputer usable program code for specializing code, the computer programproduct including: computer usable program code for gatheringintra-procedural information during a forward pass compilation of thecode; computer usable program code for traversing a call graph of thecode in reverse depth-first order; computer usable program code for, foreach procedure of code, creating a corresponding procedure controldescriptor comprising a data structure containing a list of regionprocedure control descriptors containing context dependent informationfor the corresponding candidate procedure, wherein at least onecandidate procedure contains therein at least one code region, andwherein source code of the at least one code region includes memoryallocation commands; computer usable program code for performing anintra-procedural alias analysis for all pointer variables referenced inthe corresponding candidate procedure; computer usable program code forcollecting alias relationships for each at least one candidateprocedure; computer usable program code for analyzing the aliasrelationships for arguments of pointer types, wherein analyzing isperformed at the end of the forward pass compilation when all nodes inthe call graph have been traversed; computer usable program code forrefining corresponding aliases for all pointer variables for the code;computer usable program code for computing the alias relationships forarguments of pointer type at all call sites for all procedures, wherein,for each procedure, all predecessor edges of a corresponding procedurenode are traversed; computer usable program code for constructing acorresponding bit vector to describe the alias relationships for eachcorresponding call edge of the call graph, if the corresponding calledge is from a defined procedure; computer usable program code forexamining sets of formal parameters in the corresponding procedurecontrol descriptor; computer usable program code for, for each set offormal parameters in the corresponding procedure control descriptor,computing the alias relationships for the arguments, and recording acorresponding bit value in the corresponding bit vector; computer usableprogram code for, responsive to all the arguments in a given set beingdetermined as not aliasing each other, recording a first bit value forthe given set, otherwise, recording a second bit value in the given set;computer usable program code for, responsive to the corresponding bitvectors for at least two of the predecessor edges from the definedprocedures being different, and responsive to an existence of apredecessor edge from an undefined procedure, cloning each correspondingprocedure to form a corresponding cloned procedure; computer usableprogram code for replacing a corresponding call site by calling thecorresponding cloned procedure, copying the corresponding procedurecontrol descriptor from the corresponding cloned procedure, and updatingthe call graph by moving all call edges from the defined procedure aspredecessors of the corresponding cloned procedure; computer usableprogram code for, responsive to alias bit vectors for at least twopredecessor edges from the defined procedure being different, andresponsive to at least two predecessor edges of the correspondingprocedure all being from defined procedures, selecting a correspondingprocedure as a candidate procedure for interface change and codeversioning; computer usable program code for modifying the code during abackward pass by traversing the call graph in a depth-first order and,for each defined procedure, modifying all the call sites with newinterfaces using a procedure interface descriptor; computer usableprogram code for modifying a corresponding call interface for the atleast one candidate procedure by, responsive to the at least onecandidate procedure being a candidate for interface change and codeversioning, creating a new formal parameter; computer usable programcode for creating an extra formal parameter for at least one candidateprocedure, wherein a corresponding symbol identifying the new formalparameter is created; computer usable program code for building acorresponding procedure interface descriptor for the at least onecandidate procedure; computer usable program code for recording aninterface change in the corresponding procedure interface descriptor,wherein a corresponding entry in the corresponding procedure interfacedescriptor is added for the new formal parameter, wherein thecorresponding entry contains the corresponding symbol and a type of theformal parameter; computer usable program code for modifying thecorresponding call interface with the new formal parameter; computerusable program code for updating the corresponding procedure controldescriptor with the corresponding symbol; computer usable program codefor, for each set of formal parameters in the corresponding procedurecontrol descriptor, responsive to alias bit vectors for at least twopredecessor edges from the defined procedure being different, updatingan attribute field with the corresponding symbol of the new formalparameter; computer usable program code for, for each set of formalparameters in the corresponding procedure control descriptor, responsiveto all alias bit vectors of the defined procedure being the same,indicating uniform alias relationships for the set of the formalparameters and propagating the uniform alias relationships to the atleast one candidate procedure; computer usable program code forversioning the at least one code region using a corresponding procedurecontrol descriptor condition based on the corresponding procedurecontrol descriptor; computer usable program code for creating, for eachcorresponding procedure control descriptor condition, at least one newcorresponding symbol having more precise aliasing information; andcomputer usable program code for replacing the corresponding symbolswith the at least one new corresponding symbol.
 21. A computerimplemented method for specializing code, the method comprising:performing alias analysis to identify at least one candidate code regionhaving a code specialization opportunity, wherein a code specializationopportunity occurs when the at least one candidate code region can bedisambiguated during compile time and wherein source code of the atleast one candidate code region includes memory allocation commands;selecting at least one procedure, wherein the at least one procedurecontains the corresponding at least one candidate code region;associating at least one procedure control descriptor with correspondingones of the at least one procedure, wherein each corresponding procedurecontrol descriptor comprises a data structure containing a list ofregion procedure control descriptors containing context dependentinformation and has a corresponding flag parameter of a correspondingflag, wherein the corresponding flag parameter identifies that thecorresponding at least one procedure contains the corresponding at leastone candidate code region; performing specialization, at compile time,of selected ones of the at least one candidate code region having thecode specialization opportunity, wherein specialized code regions areformed; and storing at least the specialized code regions in a memory.22. The computer implemented method of claim 21 wherein identifyingfurther comprises: building a corresponding call graph for each at leastone procedure; and traversing the call graph in reverse depth-firstorder.
 23. The computer implemented method of claim 21 whereinperforming alias analysis further comprises: performing proceduralpointer analysis to create alias relationships; and refining aliases forall pointer variables.
 24. The computer implemented method of claim 21wherein associating further comprises: traversing, in reverse depthfirst order, a corresponding call graph for each at least one coderegion.
 25. The computer implemented method of claim 21 whereinperforming code specialization further comprises: determining, for eachat least one candidate code region, whether code specialization isneeded, wherein the determination is made based on an availability of acorresponding procedure control descriptor for the corresponding atleast one procedure.
 26. A data processing system comprising: a bus; atleast one processor coupled to the bus; one or more memory elementscoupled to the bus, wherein at least one of the one or more memoryelements contains a set of instructions for specializing code, whereinthe at least one processor is adapted to carry out the set ofinstructions to: perform alias analysis to identify at least onecandidate code region having a code specialization opportunity, whereina code specialization opportunity occurs when the at least one candidatecode region can be disambiguated during compile time and wherein sourcecode of the at least one candidate code region including memoryallocation commands; select at least one procedure, wherein the at leastone procedure contains the corresponding at least one candidate coderegion; associate at least one procedure control descriptor withcorresponding ones of the at least one code procedure, wherein eachcorresponding procedure control descriptor comprises a data structurecontaining a list of region procedure control descriptors containingcontext dependent information and has a corresponding flag parameter ofa corresponding flag, wherein the corresponding flag parameteridentifies that the at least one corresponding procedure contains thecorresponding at least one candidate code region; and performspecialization, at compile time, of selected ones of the at least onecandidate code regions having the code specialization opportunity. 27.The data processing system of claim 26 wherein the at least oneprocessor is further adapted to carry out the set of instructions toidentify by carrying out the set of instructions to: build acorresponding call graph for each at least one procedure; and traversethe call graph in reverse depth-first order.
 28. The data processingsystem of claim 26 wherein the at least one processor is further adaptedto carry out the set of instructions to perform alias analysis bycarrying out the set of instructions to: perform procedural pointeranalysis to create alias relationships; and refine aliases for allpointer variables.
 29. The data processing system of claim 26 whereinthe at least one processor is further adapted to carry out the set ofinstructions to associate by carrying out the set of instructions to:traverse, in reverse depth first order, a corresponding call graph foreach at least one code region.
 30. The data processing system of claim26 wherein the at least one processor is further adapted to carry outthe set of instructions to perform code specialization by carrying outthe set of instructions to: determine, for each at least one candidatecode region, whether code specialization is needed, wherein thedetermination is made based on an availability of a correspondingprocedure control descriptor for the corresponding at least oneprocedure.